package com.example.glxt1.controller;



import com.example.glxt1.common.Result;
import com.example.glxt1.entity.User;
import com.example.glxt1.service.IUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fumeichuan
 * @since 2023-01-29
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private IUserService userService;

    @PostMapping("/save")
    public Result save(@RequestBody User user) {
        return userService.userSave(user);
    }

    @PostMapping("/delete/batch")
    public Result deleteBatch(@RequestBody List<String> ids) {
        return userService.userDeleteBatch(ids);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable String id) {
        return userService.userDelete(id);
    }

    @GetMapping("/list")
    public Result findAll() {
        return userService.userFindAll();
    }

    @GetMapping("/findOne/{id}")
    public Result findOne(@PathVariable String id) {
        return userService.userFindOne(id);
    }

    @GetMapping("/page")
    public Result findPage(@RequestParam Integer pageNum,
    @RequestParam Integer pageSize) {
        return userService.userFindPage(pageNum,pageSize);
    }

}

